/**
 * GameImpl.java
 *
 * @author Beatrice Bacelli
 * @author Luca Bedogni
 * @author Silvia Righini
 */
package unibo.lsb.server;

import java.util.ArrayList;
import java.util.List;

import unibo.lsb.logic.PlayerId;

public class GameImpl implements Game {

	String gameName = "Default game";
	int players;
	int pCount = 0;
	List<PlayerId> playersList = new ArrayList<PlayerId>();

	public GameImpl() {
		this.gameName = "Default game";
		this.players = 3;
	}

	// public GameImpl(String gameName) {
	// this.gameName = gameName;
	// }

	// public GameImpl(int players) {
	// this.players = players;
	// }

	public GameImpl(String gameName, int players) {
		this.gameName = gameName;
		this.players = players;
	}

	public void setPlayersList(List<PlayerId> playersList) {
		this.playersList = playersList;
	}

	public String getName() {
		return gameName;
	}

	public int getNumberOfPlayers() {
		return players;
	}

	public int getCount() {
		return pCount;
	}

	public boolean isFull() {
		if (pCount == players) {
			return true;
		} else {
			return false;
		}
	}

	public List<PlayerId> getListOfPlayers() {
		return playersList;
	}

	public boolean addPlayer(PlayerId playerId) {
		if (pCount < players) {
			pCount++;
			playersList.add(playerId);
			return true;
		} else {
			return false;
		}
	}

	@Override
	public String toString() {
		return gameName + ":" + players;
	}
}
